<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Utils\Enum;

class RedbillEnum
{
    public const int SORT_PAYBACK_RATE = 1;

    public const int SORT_WIN_RATE = 2;

    public const int STATUS_SALE_ING = 1;

    public const int STATUS_SALE_OFF = 2;

    public const int STATUS_RESULT_PUBLISH = 3;

    /**
     * 粉丝榜.
     */
    public const int RANK_TYPE_FANS = 1;

    /**
     * 连红榜.
     */
    public const int RANK_TYPE_RED = 2;

    /**
     * 命中榜.
     */
    public const int RANK_TYPE_HIT = 3;

    /**
     * 回报榜.
     */
    public const int RANK_TYPE_BACK = 4;

    /**
     * 足球 胜平负
     */
    public const int PLAY_TYPE_FOOTBALL_WDL = 11;

    /**
     * 足球 让球胜负
     */
    public const int PLAY_TYPE_FOOTBALL_BWL = 12;

    /**
     * 足球 大小球.
     */
    public const int PLAY_TYPE_FOOTBALL_BS = 13;

    /**
     * 篮球 胜负
     */
    public const int PLAY_TYPE_BASKETBALL_WL = 21;

    /**
     * 篮球 让分胜负
     */
    public const int PLAY_TYPE_BASKETBALL_SWL = 22;

    /**
     * 篮球 大小分.
     */
    public const int PLAY_TYPE_BASKETBALL_BS = 23;

    /**
     * 足球 胜平负
     */
    public const int SUGGEST_FB_WDL_HOME_WIN = 1; // 足球胜平负 主胜

    public const int SUGGEST_FB_WDL_DRAW = 2; // 足球胜平负 平

    public const int SUGGEST_FB_WDL_AWAY_WIN = 3; // 足球胜平负 客胜

    /**
     * 足球 让球胜负
     */
    public const int SUGGEST_FB_BWL_HOME_WIN = 4; // 足球让球主胜

    public const int SUGGEST_FB_BWL_AWAY_WIN = 5; // 足球让球客胜

    /**
     * 足球 大小球.
     */
    public const int SUGGEST_FB_BS_BIG = 6; // 足球大球

    public const int SUGGEST_FB_BS_SMALL = 7; // 足球小球

    /**
     * 篮球 胜负
     */
    public const int SUGGEST_BB_WL_HOME_WIN = 8; // 篮球主胜

    public const int SUGGEST_BB_WL_AWAY_WIN = 9; // 篮球客胜

    /**
     * 篮球 让分胜负
     */
    public const int SUGGEST_BB_SWL_HOME_WIN = 10; // 篮球让分主胜

    public const int SUGGEST_BB_SWL_AWAY_WIN = 11; // 篮球让分客胜

    /**
     * 篮球 大小分.
     */
    public const int SUGGEST_BB_BS_BIG = 12; // 大分

    public const int SUGGEST_BB_BS_SMALL = 13; // 小分

    /**
     * 足球玩法.
     */
    public const array PLAY_TYPE_FOOTBALL = [self::PLAY_TYPE_FOOTBALL_WDL, self::PLAY_TYPE_FOOTBALL_BWL, self::PLAY_TYPE_FOOTBALL_BS];

    /**
     * 篮球玩法.
     */
    public const array PLAY_TYPE_BASKETBALL = [self::PLAY_TYPE_BASKETBALL_WL, self::PLAY_TYPE_BASKETBALL_SWL, self::PLAY_TYPE_BASKETBALL_BS];

    /**
     * 足球 胜平负 建议选项.
     */
    public const array SUGGEST_GROUP_FB_WDL = [self::SUGGEST_FB_WDL_HOME_WIN, self::SUGGEST_FB_WDL_DRAW, self::SUGGEST_FB_WDL_AWAY_WIN];

    /**
     * 足球 让球胜负 建议选项.
     */
    public const array SUGGEST_GROUP_FB_BWL = [self::SUGGEST_FB_BWL_HOME_WIN, self::SUGGEST_FB_BWL_AWAY_WIN];

    /**
     * 足球 大小球 建议选项.
     */
    public const array SUGGEST_GROUP_FB_BS = [self::SUGGEST_FB_BS_BIG, self::SUGGEST_FB_BS_SMALL];

    /**
     * 篮球 胜负 建议选项.
     */
    public const array SUGGEST_GROUP_BB_WL = [self::SUGGEST_BB_WL_HOME_WIN, self::SUGGEST_BB_WL_AWAY_WIN];

    /**
     * 篮球 让分胜负 建议选项.
     */
    public const array SUGGEST_GROUP_BB_SWL = [self::SUGGEST_BB_SWL_HOME_WIN, self::SUGGEST_BB_SWL_AWAY_WIN];

    /**
     * 篮球 大小分 建议选项.
     */
    public const array SUGGEST_GROUP_BB_BS = [self::SUGGEST_BB_BS_BIG, self::SUGGEST_BB_BS_SMALL];

    /**
     * 获取玩法名称.
     * @param mixed $playTypeCode
     */
    public static function getPlayTypeName($playTypeCode): string
    {
        return match ($playTypeCode) {
            self::PLAY_TYPE_FOOTBALL_WDL => '胜平负',
            self::PLAY_TYPE_FOOTBALL_BWL => '让球胜负',
            self::PLAY_TYPE_FOOTBALL_BS => '大小球',
            self::PLAY_TYPE_BASKETBALL_WL => '胜负',
            self::PLAY_TYPE_BASKETBALL_SWL => '让分胜负',
            self::PLAY_TYPE_BASKETBALL_BS => '大小分',
            default => '未知'
        };
    }

    /**
     * 获取玩法赔率参数别名
     * @param $playTypeCode
     * @return string
     */
    public static function getOddsAlias($playTypeCode): string
    {
        return match ($playTypeCode) {
            self::PLAY_TYPE_FOOTBALL_WDL, self::PLAY_TYPE_BASKETBALL_WL => 'eu',
            self::PLAY_TYPE_FOOTBALL_BWL, self::PLAY_TYPE_BASKETBALL_SWL => 'asia',
            self::PLAY_TYPE_FOOTBALL_BS, self::PLAY_TYPE_BASKETBALL_BS => 'bs',
        };
    }

    /**
     * 获取球类玩法.
     */
    public static function getPlayList($sportId): array
    {
        switch ($sportId) {
            case MatchEnum::SPORT_FOOTBALL:
                return self::getPlayItems(self::PLAY_TYPE_FOOTBALL);
            case MatchEnum::SPORT_BASKETBALL:
                return self::getPlayItems(self::PLAY_TYPE_BASKETBALL);
            default:
                return [];
        }
    }

    /**
     * 获取玩法对应建议项.
     * @param mixed $playTypeCode
     */
    public static function getSuggestItemList($playTypeCode): array
    {
        return match ($playTypeCode) {
            self::PLAY_TYPE_FOOTBALL_WDL => self::getSuggestItems(self::SUGGEST_GROUP_FB_WDL),
            self::PLAY_TYPE_FOOTBALL_BWL => self::getSuggestItems(self::SUGGEST_GROUP_FB_BWL),
            self::PLAY_TYPE_FOOTBALL_BS => self::getSuggestItems(self::SUGGEST_GROUP_FB_BS),
            self::PLAY_TYPE_BASKETBALL_WL => self::getSuggestItems(self::SUGGEST_GROUP_BB_WL),
            self::PLAY_TYPE_BASKETBALL_SWL => self::getSuggestItems(self::SUGGEST_GROUP_BB_SWL),
            self::PLAY_TYPE_BASKETBALL_BS => self::getSuggestItems(self::SUGGEST_GROUP_BB_BS),
            default => [],
        };
    }

    /**
     * 组装建议项.
     * @param mixed $items
     */
    public static function getSuggestItems($items): array
    {
        $data = [];
        foreach ($items as $code) {
            $data[] = [
                'code' => $code,
                'name' => self::getSuggestTypeName($code),
            ];
        }
        return $data;
    }

    /**
     * 组装玩法.
     * @param mixed $items
     */
    public static function getPlayItems($items): array
    {
        $data = [];
        foreach ($items as $code) {
            $data[] = [
                'code' => $code,
                'name' => self::getPlayTypeName($code),
            ];
        }
        return $data;
    }

    /**
     * 获取建议项.
     * @param mixed $suggestTypeCode
     */
    public static function getSuggestTypeName($suggestTypeCode): string
    {
        return match ($suggestTypeCode) {
            self::SUGGEST_FB_WDL_HOME_WIN => '主胜',
            self::SUGGEST_FB_WDL_DRAW => '平',
            self::SUGGEST_FB_WDL_AWAY_WIN => '客胜',
            self::SUGGEST_FB_BWL_HOME_WIN => '让球主胜',
            self::SUGGEST_FB_BWL_AWAY_WIN => '让球客胜',
            self::SUGGEST_FB_BS_BIG => '大球',
            self::SUGGEST_FB_BS_SMALL => '小球',
            self::SUGGEST_BB_WL_HOME_WIN => '主胜',
            self::SUGGEST_BB_WL_AWAY_WIN => '客胜',
            self::SUGGEST_BB_SWL_HOME_WIN => '让分主胜',
            self::SUGGEST_BB_SWL_AWAY_WIN => '让分客胜',
            self::SUGGEST_BB_BS_BIG => '大分',
            self::SUGGEST_BB_BS_SMALL => '小分',
            default => $suggestTypeCode
        };
    }

    public static function getStatus($status): string
    {
        return match ($status) {
            self::STATUS_SALE_ING => '正在销售',
            self::STATUS_SALE_OFF => '销售结束',
            self::STATUS_RESULT_PUBLISH => '结果公布',
            default => '未知'
        };
    }
}
